# test 1
from sklearn import datasets
from pandas import DataFrame
import pandas as pd
import tensorflow as tf

x_data = datasets.load_iris().data
y_data = datasets.load_iris().target
print("x_data from datasets: \n", x_data)
print("y_data from datasets: \n", y_data)
# print("x_data_cnt", len(x_data))
# x_train = x_data[:-30]
# y_train = y_data[:-30]
# x_train = tf.cast(x_train, tf.float32)
# train_cnt = 0
# train_db = tf.data.Dataset.from_tensor_slices((x_train, y_train)).batch(32)
# for step, (x_data, y_data) in enumerate(train_db):
#     print(step, x_data, y_data)
#     train_cnt += 1
# print(train_cnt)

# x_data = DataFrame(x_data, columns=['sepal-length', 'sepal-width', 'petal-length', 'sepal-width'])
# # pd.set_option('display.unicode.east_asian_width', True)
# pd.set_option('display.max_colwidth', 20)
# print("x_data add index: \n", x_data)
#
# x_data['category'] = y_data
# print("x_data add a column: \n", x_data)

# test 2
# import numpy as np
# np.random.seed(42)
#
# # 生成随机数
# print(np.random.rand())
# print(np.random.rand())
#
# # 再次设置相同的种子
# np.random.seed(42)
#
# # 生成的随机数与之前相同
# print(np.random.rand())
# print(np.random.rand())

# test 3
# x_data = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
# print(x_data[:-3])
# print(x_data[-3:])

# test 4
# batch_data = x_data.batch(2)
# for batch in batch_data:
#     print(batch.numpy)

# test 5 每次初始化seed后，shuffle的打乱顺序一致
# y_data = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
# np.random.seed(116)
# np.random.shuffle(x_data)
# print(x_data)
# np.random.seed(116)
# np.random.shuffle(y_data)
# print(y_data)

# test 6
# import tensorflow as tf
# import numpy as np
#
# data = np.array([1, 2, 3, 4, 5])
#
# # 使用 from_tensor_slices 创建 Dataset
# dataset = tf.data.Dataset.from_tensor_slices(data)
#
# # 遍历 Dataset
# for element in dataset:
#     print(element.numpy())